home *** CD-ROM | disk | FTP | other *** search
/ boe.pres.k12.wv.us / boe.pres.k12.wv.us.zip / boe.pres.k12.wv.us / Utilities / Xerox Workcentre 5335 / Windows Scan / 32-bit_x86 / Francais / cpsimage.cab / data / xipProcs / FrameIt.proc < prev    next >
Text File  |  2009-03-16  |  4KB  |  138 lines

  1. /* @FrameIt
  2.   // DESCRIPTION
  3.   Puts a simple gradient highlighted frame around an image.  The default
  4.   size is 10 pixels.
  5.  
  6.   General syntax:
  7.     XIPIMAGE out = FrameIt (inImg: input [, optionals] );
  8.  
  9.   Optional Arguments:
  10.    size         : INTEGER   Frame size in pixels
  11.    light        : STRING    Direction of light
  12.    color        : LIST      Color in r,g,b to use, e.g., (0,128,200)
  13.    transparency : INTEGER   Percent transparency
  14.  
  15.   Light direction is from the upper left by default.  You can set the
  16.   direction with "light" option.  Use the following strings:
  17.  
  18.    FrameIt ( light:"ul" ,...) = light direction from upper left
  19.    FrameIt ( light:"ur" ,...) = light direction from upper right
  20.    FrameIt ( light:"lr" ,...) = light direction from lower right
  21.    FrameIt ( light:"ll" ,...) = light direction from lower left
  22.    FrameIt ( light:"in" ,...) = light eminates from in the frame
  23.    FrameIt ( light:"out",...) = light eminates from outside the frame
  24.    FrameIt ( light:"top",...) = light is on top of the frame
  25.    FrameIt ( light:"bot",...) = light eminates from underneath the frame
  26.  
  27.   // Example:
  28.    // Given that you already have an image "img", the following gives
  29.    // a 25 pixel wide frame, light from the top, with a redish cast.
  30.    img = FrameIt (inImg: img,
  31.                    size: 25,
  32.                   light: "top",
  33.                   color: (200,55,55),
  34.            transparency: 50);
  35. */
  36. PROCEDURE FrameIt (XIPIMAGE inImg,
  37.                     INTEGER size,
  38.                     STRING  light,
  39.                     LIST     color,
  40.                     INTEGER transparency)
  41.   RETURNS (XIPIMAGE out)
  42. {
  43.   INTEGER j;
  44.   LIST gp1 = (1,0,1,0);  // Set the list of sides to use, lt,rt,top,bot
  45.   LIST gp2 = (0,1,0,1);  // Set the list of sides to use, lt,rt,top,bot
  46.  
  47.   // If no size set
  48.   if (size == 0) size = 10;
  49.  
  50.   // pull the image through
  51.   INTEGER w = inImg.imageWidth;
  52.   INTEGER h = inImg.imageHeight;
  53.  
  54.   if (color) {
  55.     inImg = inImg.exec();
  56.     w = inImg.imageWidth;
  57.     h = inImg.imageHeight;
  58.     }
  59.  
  60.   // Set gradient values
  61.   DOUBLE low    = 32;
  62.   DOUBLE high   = 200;
  63.   DOUBLE offset = (high-low) / size;
  64.  
  65.   // Set the frame instances
  66.   if (light == "ur")
  67.     { gp1 = (0,1,1,0); gp2 = (1,0,0,1); }
  68.  
  69.   else if (light == "lr")
  70.     { gp1 = (0,1,0,1); gp2 = (1,0,1,0); }
  71.  
  72.   else if (light == "ll")
  73.     { gp1 = (1,0,0,1); gp2 = (0,1,1,0); }
  74.  
  75.   else if (light == "in") {
  76.     gp1 = (1,1,1,1);
  77.     for (j=0; j<size; j=j+1;)
  78.       inImg = inImg.frame (outside: 1, thick: gp1, value: (high -j * offset));
  79.     out = inImg;
  80.     }
  81.  
  82.   else if (light == "top") {
  83.     gp1 = (1,1,1,1);
  84.     offset = offset * 2;
  85.     for (j=0; j<size/2; j=j+1;)
  86.       inImg = inImg.frame (outside: 1, thick: gp1, value: (low +j * offset));
  87.     if ( (size/2)*2 != size)
  88.       inImg = inImg.frame (outside: 1, thick: gp1, value: (high) );
  89.     for (j=0; j<size/2; j=j+1;)
  90.       inImg = inImg.frame (outside: 1, thick: gp1, value: (high-j * offset));
  91.     out = inImg;
  92.     }
  93.  
  94.   else if (light == "bot") {
  95.     gp1 = (1,1,1,1);
  96.     offset = offset * 2;
  97.     for (j=0; j<size/2; j=j+1;)
  98.       inImg = inImg.frame (outside: 1, thick: gp1, value: (high-j * offset));
  99.     if ( (size/2)*2 != size)
  100.       inImg = inImg.frame (outside: 1, thick: gp1, value: (low) );
  101.     for (j=0; j<size/2; j=j+1;)
  102.       inImg = inImg.frame (outside: 1, thick: gp1, value: (low +j * offset));
  103.     out = inImg;
  104.     }
  105.  
  106.   else if (light == "out") {
  107.     gp1 = (1,1,1,1);
  108.     for (j=0; j<size; j=j+1;)
  109.       inImg = inImg.frame (outside: 1, thick: gp1, value: (low +j * offset));
  110.     out = inImg;
  111.     }
  112.  
  113.   // Default processing adds two sides at a time
  114.   if (!out)
  115.     for (j=0; j<size; j=j+1;)
  116.       inImg = inImg.frame (outside: 1, thick: gp1, value: (low  +j * offset)
  117.                   ).frame (outside: 1, thick: gp2, value: (high -j * offset));
  118.  
  119.   if (color) {
  120.     INTEGER r = color[0];
  121.     INTEGER g = color[1];
  122.     INTEGER b = color[2];
  123.  
  124.     if (transparency == 0)
  125.       transparency = 128;
  126.     else
  127.       transparency = 256.0 - (transparency/100.0 * 256.0);
  128.     inImg = inImg.tfill (outside: 1,
  129.                           window: (size,size,w,h),
  130.                           colors: (r,g,b),
  131.                     transparency: transparency);
  132.     }
  133.  
  134.  
  135.   // Set the output image
  136.   out = inImg;
  137. }
  138.